package com.ruijie.autotest.log.validation.hangzhoudewangxin.IMCMP;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.ruijie.autotest.log.core.validate.IValidator;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

import static com.ruijie.autotest.log.impl.validate.SqlExistingValidator.sqlExistingVerificationOf;

@SpringBootConfiguration
public class Config {
	@Bean
	public DataSource dataSource() {
		return new ComboPooledDataSource("remote");
	}

	@Bean
	public IValidator orgNameValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.org_name", dataSource);
	}

	@Bean
	public IValidator orgCodeValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.org_code", dataSource);
	}

	@Bean
	public IValidator addressValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.address", dataSource);
	}

	@Bean
	public IValidator contactorNameValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.contactor", dataSource);
	}

	@Bean
	public IValidator contactorTelValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.contactor_tel", dataSource);
	}

	@Bean
	public IValidator contactorMailValidator(DataSource dataSource) {
		return sqlExistingVerificationOf("s_security_org.contactor_mail", dataSource);
	}
}
